// Seth Andrews - Program: McCabe.java - Finding McCabe's Number

import java.io.File;
import java.util.Scanner;
import java.util.regex.*;

public class McCabe extends Object{
    public static void main(String[] args) throws Exception {
        // Instantiate count
    	int count = 0;

        // Open file into scanner
        File f = new File("McCabe.java");
        Scanner input = new Scanner(f);

        // Regular Expression Patterns used
        Pattern exclude3 = Pattern.compile("\"");
        Pattern exclude4 = Pattern.compile("//");
        Pattern p1 = Pattern.compile("while");
        Pattern p2 = Pattern.compile("if");
        Pattern p3 = Pattern.compile("&&");

        while (input.hasNext()) {
        	// Exclude for the parenthesis
        	if (input.hasNext(exclude3)) {
        		input.next();
        		while (input.hasNext()) {
        			if (input.hasNext(exclude3)) {
                		input.next();
                		break;
        			}
        			input.next();
        		}
        		continue;
        	}

        	// Exclude documentation
        	if (input.hasNext(exclude4)) {
        		input.nextLine();
        		continue;
        	}

        	// McCabe's Count
            while (input.hasNext(p1) || input.hasNext(p2) || input.hasNext(p3)) {
                count++;
                break;
            }
            input.next();
        }

        // Display McCabe's Number
        input.close();
        System.out.println(count + 1);

    }

}

